package com.my.yc.homework;

import com.google.gson.Gson;
import com.my.yc.bean.Result;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "AddExpServlet", value = "/AddExpServlet")
public class AddExpServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String exp = request.getParameter("exp");
        HttpSession session = request.getSession();
        if (exp != null || exp.isEmpty() == false){
            session.setAttribute("exp", exp);
        }
        Result res = new Result(1, "添加成功!", null);
        String json = new Gson().toJson(res);
        response.getWriter().append(json);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
